package com.ymatou.iapi.godmch.testcase;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.internal.runners.TestMethod;

import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.createagentBean;
import com.ymatou.iapi.godmch.parameter.editmchBean;
import com.ymatou.iapi.godmch.parameter.getInviteDistributorPicBean;
import com.ymatou.iapi.godmch.parameter.registerBean;
import com.ymatou.iapi.godmch.parameter.registerByCodeBean;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.createSupplierCodeCall;
import com.ymatou.iapi.godmch.service.createagentCall;
import com.ymatou.iapi.godmch.service.getInviteCpsPicCall;
import com.ymatou.iapi.godmch.service.getInviteDistributorPicCall;
import com.ymatou.iapi.godmch.service.registerByCodeCall;
import com.ymatou.iapi.godmch.service.registerCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.business.service.shenqi.SqDistributorService;
import com.ymttest.database.model.agent_type;
import com.ymttest.database.model.country_info;
import com.ymttest.database.model.invite_code;
import com.ymttest.database.model.mch_info;
import com.ymttest.database.model.mch_relation;
import com.ymttest.database.model.godmch.mch_config;
import com.ymttest.database.model.godmch.mch_configExample;
import com.ymttest.database.sqlwapper.godmch.agent_typeWapper;
import com.ymttest.database.sqlwapper.godmch.country_infoWapper;
import com.ymttest.database.sqlwapper.godmch.invite_codeWapper;
import com.ymttest.database.sqlwapper.godmch.mch_configWapper;
import com.ymttest.database.sqlwapper.godmch.mch_infoWapper;
import com.ymttest.database.sqlwapper.godmch.mch_relationWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*公有云注册
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_register{
	private static registerBean bean;
	private static registerCall call;
	private static mch_infoWapper mchInfoWapper = new mch_infoWapper();
	private static country_infoWapper countryinfoWapper = new country_infoWapper();
	private static invite_codeWapper invitecodeWapper = new invite_codeWapper();
	private static mch_relationWapper mchrelationWapper = new mch_relationWapper();
	private static agent_typeWapper agenttypeWapper = new agent_typeWapper();
	private mch_configWapper mchconfigWapper=new mch_configWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("公有云注册");
	}

	@Before
	public void caseUp() {
		bean=new registerBean();
		call=new registerCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	/**
	 * 
	 * @param userId_channl
	 *            渠道id
	 * @param isVip
	 *            是否是vip
	 * @param isCurrency
	 *            渠道商为国外货币,代理是否为国内
	 * @param userId_agent
	 *            代理用户
	 * @throws InterruptedException
	 * @throws JSONException
	 */
	private void checkVerify(int userId_channl,Integer userType, boolean isVip, boolean isCHN, int... userId_agent) throws InterruptedException, JSONException {
		// 获取客服信息
		Map<String, Object> map = new HashMap();
		map.put("mchId", userId_channl);
		mch_info mchInfo = mchInfoWapper.selectby(map).get(0);
		// 获取国家编号
		country_info countryinfo = countryinfoWapper.selectByPrimaryKey(bean.getCountry());
		Logger.verifyEquals("200", call.getStatusCode1(), "验证返回成功status值");
		Logger.verifyEquals(userType, call.getUserType(), "验证返回成功userType值");
		Logger.verifyEquals("请求成功", call.getMessage(), "验证返回成功Message值");
		Logger.verifyEquals(bean.getCountry(), mchInfo.getCountry(), "验证数据库mch_info对应的字段Country");
		Logger.verifyEquals(countryinfo.getCurrency(), mchInfo.getCurrency(), "验证数据库mch_info对应的字段Currency");

		Logger.verifyEquals(isVip == true ? 1 : 0, mchInfo.getVip(), "验证数据库mch_info对应的字段Vip");
		Logger.verifyEquals(0, mchInfo.getState(), "验证数据库mch_info对应的字段State");
		Logger.verifyNotNull(mchInfo.getCreateTime(), "验证数据库mch_info对应的字段CreateTime");
		Logger.verifyNotNull(mchInfo.getUpdateTime(), "验证数据库mch_info对应的字段UpdateTime");
		if (mchInfo.getAgent() == 1)// 代理
		{
			// mch_info
			if (isCHN == true)
				Logger.verifyEquals(0, mchInfo.getChannels(), "验证数据库mch_info对应的字段Channel");
			else
				Logger.verifyEquals(1, mchInfo.getChannels(), "验证数据库mch_info对应的字段Channel");

			Logger.verifyEquals(1, mchInfo.getAgent(), "验证数据库mch_info对应的字段Agent");
			// mch_relation
			List<mch_relation> mchrelations = mchrelationWapper.selectByPrimaryKey(userId_agent[0], userId_channl);
			for (mch_relation relation : mchrelations) {
				// agent_type
				Map<String, Object> map2 = new HashMap();
				map2.put("mchId", relation.getParentMchId());
				map2.put("agentType", relation.getAgentType());
				List<agent_type> agenttypeList = agenttypeWapper.selectby(map);
				Logger.verifyEquals(true, agenttypeList.size() > 0, "验证数据库mch_relation对应的 一级代理 字段agentType 存在");
				// invite_code
				Map<String, Object> map3 = new HashMap();
				map3.put("mchId", relation.getParentMchId());
				map3.put("inviteCode", relation.getInviteCode());
				List<invite_code> inviteCodeList = invitecodeWapper.selectby(map3);
				Logger.verifyEquals(true, inviteCodeList.size() > 0, "验证数据库mch_relation对应的 一级代理 字段inviteCode 存在");
			}
            //代理 
			map = new HashMap();
			map.put("mchId", userId_agent[0]);
			mch_info mchInfo_agent = mchInfoWapper.selectby(map).get(0);
			//Logger.verifyEquals(true,bean2.getCountry()=="CHN"?mchInfo_agent.getChannels()==0:mchInfo_agent.getChannels()==1, "验证channels");
			Logger.verifyEquals(1,mchInfo_agent.getAgent(), "验证Agent");
			
		} else// 渠道
		{
			Logger.verifyEquals(1, mchInfo.getChannels(), "验证数据库mch_info对应的字段Channel");
			Logger.verifyEquals(0, mchInfo.getAgent(), "验证数据库mch_info对应的字段Agent");
		}

		//支付方式 新增20191014 
		Logger.verifyEquals(2, mchInfo.getPayMode(), "验证数据库mch_info对应的字段PayMode");
		//支付宝支付方式 新增20191224
		Logger.verifyEquals(0,mchInfo.getAliPayMode(), "验证AliPayMode");
		if(call.getUserType()!=1 && call.getUserType()!=4 && call.getUserType()!=6){
			//新增 风控 20200227 summing
	        mch_configExample example=new mch_configExample();
	        example.createCriteria().andMchIdEqualTo(call.getUserId());
	        mch_config mchconfig=mchconfigWapper.selectByExample(example).get(0);
	        //新增加商户默认风控值
	        String productRiskAmount=EnvSetup.getData("productRiskAmount");
	        String tradeRiskAmount=EnvSetup.getData("tradeRiskAmount");
	        Logger.verifyEquals(mchconfig.getProductRiskAmount().stripTrailingZeros().toPlainString(),productRiskAmount, "验证数据库mch_confog 中字段ProductRiskAmount与传入的ProductRiskAmount是否一致");
	        Logger.verifyEquals(mchconfig.getTradeRiskAmount().stripTrailingZeros().toPlainString(),tradeRiskAmount, "验证数据库mch_confog 中字段TradeRiskAmount与传入的TradeRiskAmount是否一致");
		}
        //结算币种 新增 20200407 商户所在的国家如果不支持本国币种结算，落地USD，否则落地对应国家币种
        Logger.verifyEquals(countryinfo.getSupportLocalCurrency()!=1?"USD":countryinfo.getCurrency(),mchInfo.getSettlementCurrency(),"验证数据库mch_info对应的字段settlementCurrency(商户所在的国家如果不支持本国币种结算，落地USD，否则落地对应国家币种)");
      
        if(bean.getInviteCode()!=null && bean.getInviteCode().equals("GNQDS"))
        {
        	Logger.verifyEquals(2, mchInfo.getMchShareType(), "验证国内渠道商的店铺分享类型为H5");
        	Logger.verifyEquals(2, mchInfo.getPayMode(), "验证国内渠道商的payMode为飞界国际电子商务");
        	Logger.verifyEquals(1, mchInfo.getDomesticPayMode(), "所有商户的国内支付通道默认都设置为盛付通-海鲲科技");
        }
        
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_001() {
		Logger.start(true,"公有云注册-5渠道商直接注册-返回成功");
		try {
			
			bean.setCountry("USA");
			bean.setMobile(TestDataManager.getPhoneNum());
			bean.setPassword("www123");
			bean.setAppSource(60);// 代购神器买家端小程序
			bean.setTerminalSource(0);// 其他 default
			bean.setAppKey("appsqseller");
			
			call.setData(bean);
			call.callService();			
			
			checkVerify(call.getUserId(),5,false,false);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_002() {
		Logger.start(true,"公有云注册-1代理-渠道商-邀请码邀请代理-返回成功");
		try {
			//注册渠道商
			bean=GodmchManageCallService.initRegister();
			call=GodmchManageCallService.registerCall(bean);
			Integer channlId=call.getUserId();
			//渠道商邀请码
			CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(call.getUserId());
			CreateCodeCall createcall = GodmchManageCallService.createCodeCall(createCodeBean);
			//邀请码再注册代理
			bean=GodmchManageCallService.initRegister();
			bean.setInviteCode(createcall.getCode());
			call=GodmchManageCallService.registerCall(bean);		
			Integer agentId=call.getUserId();
			checkVerify(channlId,1,false,false,agentId);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_003() {
		Logger.start(true,"公有云注册-vip渠道商-返回成功");
		try {
			bean.setCountry("USA");
			bean.setMobile(TestDataManager.getPhoneNum());
			bean.setPassword("www123");
			bean.setAppSource(60);// 代购神器买家端小程序
			bean.setTerminalSource(0);// 其他 default
			bean.setAppKey("appsqseller");
			
			call.setData(bean);
			call.callService();			
		    //设置vip
			GodmchManageCallService.SetVip(call.getUserId());
			checkVerify(call.getUserId(),5,true,false);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_004() {
		Logger.start(true,"公有云注册-vip渠道商-邀请代理-返回成功");
		try {
			//注册渠道商
			bean=GodmchManageCallService.initRegister();
			call=GodmchManageCallService.registerCall(bean);
			Integer channlId=call.getUserId();
		    //设置vip
			GodmchManageCallService.SetVip(call.getUserId());
			//渠道商邀请码
			CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(call.getUserId());
			//createCodeBean.setAgentModel(1);
			CreateCodeCall createcall = GodmchManageCallService.createCodeCall(createCodeBean);
			//邀请码再注册代理
			bean=GodmchManageCallService.initRegister();
			bean.setInviteCode(createcall.getCode());
			call=GodmchManageCallService.registerCall(bean);		
			Integer agentId=call.getUserId();
			checkVerify(channlId,1,true,false,agentId);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_004_1() {
		Logger.start(true,"公有云注册-渠道商-邀请代理-代理再邀请代理-返回成功");
		try {
			//注册渠道商
			bean=GodmchManageCallService.initRegister();
			call=GodmchManageCallService.registerCall(bean);
			Integer channlId=call.getUserId();
		    //设置vip
			GodmchManageCallService.SetVip(call.getUserId());
			//渠道商邀请码1
			CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(call.getUserId());
			CreateCodeCall createcall = GodmchManageCallService.createCodeCall(createCodeBean);
			//邀请码再注册代理1
			bean=GodmchManageCallService.initRegister();
			bean.setInviteCode(createcall.getCode());
			call=GodmchManageCallService.registerCall(bean);
			Integer agentId1=call.getUserId();
			
			//渠道商邀请码2
			createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(call.getUserId());
			createcall = GodmchManageCallService.createCodeCall(createCodeBean);
			
			//邀请码再注册代理2
			bean=GodmchManageCallService.initRegister();
			bean.setInviteCode(createcall.getCode());
			call=GodmchManageCallService.registerCall(bean);	
			Integer agentId2=call.getUserId();
			
			checkVerify(channlId,1,true,false,agentId1);
			checkVerify(agentId1,1,false,false,agentId2);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_005() {
		Logger.start(true,"公有云注册-渠道商-邀请两个代理(同一邀请码注册两个代理)-返回成功");
		try {
			//注册渠道商
			bean=GodmchManageCallService.initRegister();
			call=GodmchManageCallService.registerCall(bean);
			Integer channlId=call.getUserId();
			//渠道商邀请码1
			CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(call.getUserId());
			CreateCodeCall createcall = GodmchManageCallService.createCodeCall(createCodeBean);
			//邀请码再注册代理1
			bean=GodmchManageCallService.initRegister();
			bean.setInviteCode(createcall.getCode());
			call=GodmchManageCallService.registerCall(bean);
			Integer agentId1=call.getUserId();
			//邀请码再注册代理2
			bean=GodmchManageCallService.initRegister();
			bean.setInviteCode(createcall.getCode());
			call=GodmchManageCallService.registerCall(bean);	
			Integer agentId2=call.getUserId();
			
			checkVerify(channlId,1,false,false,agentId1);
			checkVerify(channlId,1,false,false,agentId2);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_007() {
		Logger.start(true,"公有云注册-vip渠道商-纯代理商发展下级代理-返回成功");
		try {
			//注册渠道商
			bean=GodmchManageCallService.initRegister();
			call=GodmchManageCallService.registerCall(bean);
			Integer channlId=call.getUserId();
		    //设置vip
			GodmchManageCallService.SetVip(call.getUserId());
			//渠道商邀请码1
			CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(call.getUserId());
			CreateCodeCall createcall = GodmchManageCallService.createCodeCall(createCodeBean);
			//邀请码再注册代理1
			registerBean bean1=GodmchManageCallService.initRegister();
			bean1.setCountry("CHN");
			bean1.setInviteCode(createcall.getCode());
			call=GodmchManageCallService.registerCall(bean1);
			Integer agentId1=call.getUserId();
			
			//渠道商邀请码2
			createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(call.getUserId());
			createcall = GodmchManageCallService.createCodeCall(createCodeBean);
			
			//邀请码再注册代理2
			registerBean bean2=GodmchManageCallService.initRegister();
			//bean2.setCountry("CHN");
			bean2.setInviteCode(createcall.getCode());
			call=GodmchManageCallService.registerCall(bean2);	
			Integer agentId2=call.getUserId();
			
			Logger.comment("######### agent1:"+agentId1);
			checkVerify(channlId,1,true,true,agentId1);
			//Logger.comment("######### agent2:"+agentId2);
			//checkVerify(agentId1,1,false,false,agentId2);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_008() {
		Logger.start(true,"公有云注册-有邀请码(国内代理)-渠道支付类型是盛付通-代理非盛付通-返回成功");
		try {
			//注册渠道商
			bean=GodmchManageCallService.initRegister();
			call=GodmchManageCallService.registerCall(bean);
			Integer channlId=call.getUserId();
			//设置渠道支付类型是盛付通
			GodmchManageCallService.SetPayMode(channlId);
			
			//渠道商邀请码
			CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(call.getUserId());
			CreateCodeCall createcall = GodmchManageCallService.createCodeCall(createCodeBean);
			//邀请码再注册代理
			bean=GodmchManageCallService.initRegister();
			bean.setInviteCode(createcall.getCode());
			call=GodmchManageCallService.registerCall(bean);		
			Integer agentId=call.getUserId();
			
            // 获取客服信息
			Map<String, Object> map = new HashMap();
			map.put("mchId", channlId);
			mch_info mchInfo = mchInfoWapper.selectby(map).get(0);
			// 获取国家编号
			country_info countryinfo = countryinfoWapper.selectByPrimaryKey(bean.getCountry());
			Logger.verifyEquals("200", call.getStatusCode1(), "验证返回成功status值");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证返回成功Message值");
			Logger.verifyEquals(bean.getCountry(), mchInfo.getCountry(), "验证数据库mch_info对应的字段Country");
			Logger.verifyEquals(countryinfo.getCurrency(), mchInfo.getCurrency(), "验证数据库mch_info对应的字段Currency");

			Logger.verifyEquals(0, mchInfo.getVip(), "验证数据库mch_info对应的字段Vip");
			Logger.verifyEquals(0, mchInfo.getState(), "验证数据库mch_info对应的字段State");
			Logger.verifyNotNull(mchInfo.getCreateTime(), "验证数据库mch_info对应的字段CreateTime");
			Logger.verifyNotNull(mchInfo.getUpdateTime(), "验证数据库mch_info对应的字段UpdateTime");
			if (mchInfo.getAgent() == 1)// 代理
			{
				// mch_info
				
			    Logger.verifyEquals(1, mchInfo.getChannels(), "验证数据库mch_info对应的字段Channel");

				Logger.verifyEquals(1, mchInfo.getAgent(), "验证数据库mch_info对应的字段Agent");
				// mch_relation
				List<mch_relation> mchrelations = mchrelationWapper.selectByPrimaryKey(agentId, channlId);
				for (mch_relation relation : mchrelations) {
					// agent_type
					Map<String, Object> map2 = new HashMap();
					map2.put("mchId", relation.getParentMchId());
					map2.put("agentType", relation.getAgentType());
					List<agent_type> agenttypeList = agenttypeWapper.selectby(map);
					Logger.verifyEquals(true, agenttypeList.size() > 0, "验证数据库mch_relation对应的 一级代理 字段agentType 存在");
					// invite_code
					Map<String, Object> map3 = new HashMap();
					map3.put("mchId", relation.getParentMchId());
					map3.put("inviteCode", relation.getInviteCode());
					List<invite_code> inviteCodeList = invitecodeWapper.selectby(map3);
					Logger.verifyEquals(true, inviteCodeList.size() > 0, "验证数据库mch_relation对应的 一级代理 字段inviteCode 存在");	
				}

			} else// 渠道
			{
				Logger.verifyEquals(1, mchInfo.getChannels(), "验证数据库mch_info对应的字段Channel");
				Logger.verifyEquals(0, mchInfo.getAgent(), "验证数据库mch_info对应的字段Agent");
			}
			//支付方式 新增20191014 
			Logger.verifyEquals(3, mchInfo.getPayMode(), "验证数据库mch_info对应的字段PayMode");
			//支付宝支付方式 新增20191224
			Logger.verifyEquals(0,mchInfo.getAliPayMode(), "验证AliPayMode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_009() {
		Logger.start(true,"公有云注册-专属邀请码GNQDS注册为国内渠道商(国内身份商专属邀请码(disconfig配置GNQDS)注册为渠道商，无代理商身份)");
		try {
			bean.setCountry("CHN");
			bean.setMobile(TestDataManager.getPhoneNum());
			bean.setPassword("www123");
			bean.setAppSource(60);// 代购神器买家端小程序
			bean.setTerminalSource(0);// 其他 default
			bean.setAppKey("appsqseller");
			bean.setInviteCode("GNQDS1");
			call.setData(bean);
			call.callService();	

			checkVerify(call.getUserId(),5,false,true);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_009_1() {
		Logger.start(true,"公有云注册-专属邀请码GNQDS注册为国内渠道商(国内身份商专属邀请码(disconfig配置GNQDS)注册为渠道商，无代理商身份)");
		try {
			bean.setCountry("CHN");
			bean.setMobile(TestDataManager.getPhoneNum());
			bean.setPassword("www123");
			bean.setAppSource(60);// 代购神器买家端小程序
			bean.setTerminalSource(0);// 其他 default
			bean.setAppKey("appsqseller");
			bean.setInviteCode("GNQDS1");
			call.setData(bean);
			call.callService();	
			Integer channlId=call.getUserId();
			
			//渠道商邀请码
			CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(call.getUserId());
			CreateCodeCall createcall = GodmchManageCallService.createCodeCall(createCodeBean);
			//邀请码再注册代理
			registerBean bean2=GodmchManageCallService.initRegister();
			bean2.setInviteCode(createcall.getCode());
			call=GodmchManageCallService.registerCall(bean2);		
			Integer agentId=call.getUserId();
			
			checkVerify(channlId,1,false,true,agentId);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_010() {
		Logger.start(true,"公有云注册-4分销员-返回成功");
		try {

			bean=GodmchManageCallService.initRegister();
			call=GodmchManageCallService.registerCall(bean);
            Integer mchId=call.getUserId();
			editmchBean editBean=GodmchManageCallService.IniteditmachBean(mchId);
			GodmchManageCallService.editmachCall(editBean);
            Logger.comment("###########商户："+mchId);
            
            Logger.comment("###########商户审核：");
            SqDistributorService.createAutoAuditDistributor((long)mchId);
            
        	//独立商户邀请分享图
            getInviteDistributorPicBean getInviteDistributorPicBean=GodmchManageCallService.initGetInviteDistributorPicBean(mchId);
            getInviteDistributorPicCall getInviteDistributorPicCall=GodmchManageCallService.getInviteDistributorPicBeanCall(getInviteDistributorPicBean);
            Logger.comment("###########商户图片：");
           
            registerBean  bean2=GodmchManageCallService.initRegister();
            bean2.setInviteCode(getInviteDistributorPicCall.getResult().get("inviteCode").getAsString());
            call=GodmchManageCallService.registerCall(bean2);
			Integer agentId=call.getUserId();
			
			checkVerify(mchId,4,false,false,agentId);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_011() {
		Logger.start(true,"公有云注册-6分销机构-返回成功");
		try {
			bean=GodmchManageCallService.initRegister();
			call=GodmchManageCallService.registerCall(bean);
            Integer mchId=call.getUserId();
			editmchBean editBean=GodmchManageCallService.IniteditmachBean(mchId);
			GodmchManageCallService.editmachCall(editBean);
            Logger.comment("###########商户："+mchId);
            
            Logger.comment("###########商户审核：");
            SqDistributorService.createAutoAuditDistributor((long)mchId);
            
        	//独立商户邀请分享图
            String inviteCode= GodmchManageCallService.getInviteDistributorOrganizationPic(mchId).getInviteCode();
            Logger.comment("###########商户图片：");
            
            registerBean  bean2=GodmchManageCallService.initRegister();
            bean2.setInviteCode(inviteCode);
            call=GodmchManageCallService.registerCall(bean2);
			Integer agentId=call.getUserId();
			
			checkVerify(mchId,6,false,false,agentId);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_register_012() {
		Logger.start(true,"公有云注册-分销小店-返回失败(平台商户不支持继承型代理,创建code 就不支持2分销小店)");
		try {
			bean=GodmchManageCallService.initRegister();
			call=GodmchManageCallService.registerCall(bean);
            Integer mchId=call.getUserId();
			editmchBean editBean=GodmchManageCallService.IniteditmachBean(mchId);
			GodmchManageCallService.editmachCall(editBean);
            Logger.comment("###########商户："+mchId);
            
        	//邀请码
			CreateCodeBean createCodeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(mchId, true);
			// 创建代理类型
			createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(mchId);
			createagentBean.setAgentMode(2);
			createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
			
			//查询类型
			agent_typeWapper agentTypewapper = new agent_typeWapper();
			Map<String, Object> map = new HashMap();
			map.put("mchId", mchId);
			List<agent_type> agenttypeList = agentTypewapper.selectby(map);
			createCodeBean.setRoleType(agenttypeList.get(2).getAgentType());
			
			CreateCodeCall createCodeCall=GodmchManageCallService.createCodeCall(createCodeBean);
            
            registerBean  bean2=GodmchManageCallService.initRegister();
            bean2.setInviteCode(createCodeCall.getCode());
            call=GodmchManageCallService.registerCall(bean2);
			Integer agentId=call.getUserId();
			
			//checkVerify(mchId,6,false,false,agentId);				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_register_013() {
		Logger.start(true,"公有云注册-独立供货商邀请码注册平台商户-返回失败");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();
            createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
			//独立供货商
            registerByCodeBean registerByCodeBean=GodmchManageCallService.initRegisterByCode(mchId, createSupplierCodeCall.getCode());
            registerByCodeCall registerCodeCall=GodmchManageCallService.registerByCodeCall(registerByCodeBean);
            //供货商Code
            createSupplierCodeCall createSupplierCodeCall2=GodmchManageCallService.createSupplierCode(registerCodeCall.getRegMchId());
            
			bean.setCountry("USA");
			bean.setMobile(TestDataManager.getPhoneNum());
			bean.setPassword("www123");
			bean.setAppSource(60);// 代购神器买家端小程序
			bean.setTerminalSource(0);// 其他 default
			bean.setAppKey("appsqseller");
			bean.setInviteCode(createSupplierCodeCall2.getCode());
			call.setData(bean);
			call.callService();	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_register_014() {
		Logger.start(true,"公有云注册-支持本土(AUS)-商户所在的国家如果不支持本国币种结算,落地USD,否则落地对应国家币种");
		try {
			
			bean.setCountry("AUS");
			bean.setMobile(TestDataManager.getPhoneNum());
			bean.setPassword("www123");
			bean.setAppSource(60);// 代购神器买家端小程序
			bean.setTerminalSource(0);// 其他 default
			bean.setAppKey("appsqseller");
			
			call.setData(bean);
			call.callService();			
			
			checkVerify(call.getUserId(),5,false,false);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
//	@Test
//	@Category({P1.class})
//	@TestCase
//	public void Tc_register_015() {
//		Logger.start(true,"公有云注册-邀请CPS分享图片-CPS注册");
//		try {
//			
////			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
////	        createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
//			//Integer mchId=GodmchManageCallService.CreateSellerMch();
//			Integer mchId=501571125;
//	        Thread.sleep(5000);
//	        //Integer mchId=createIndepMchCall.getmchId();
//			getInviteCpsPicCall getInviteCpsPicCall=GodmchManageCallService.getInviteCpsPic(mchId);
//			
//			bean.setCountry("AUS");
//			bean.setMobile(TestDataManager.getPhoneNum());
//			bean.setPassword("www123");
//			bean.setAppSource(60);// 代购神器买家端小程序
//			bean.setTerminalSource(0);// 其他 default
//			bean.setAppKey("appsqseller");
//			
//			bean.setInviteCode(getInviteCpsPicCall.getInviteCode());
//			call.setData(bean);
//			call.callService();			
//			
//			//checkVerify(call.getUserId(),5,false,false);			
//			
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
}